package com.stefanini.pe.bbva.iivs.in.rpt;

import java.util.List;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

import com.stefanini.pe.bbva.iivs.in.to.HistSolicitud;

public class DataSourceReporte  implements JRDataSource {

	private List lstDatos;	
	private int index = -1;
	
	public DataSourceReporte(List lstDatos) {
		this.lstDatos=lstDatos;	
	}

	public static void main(String[] args) {

	}

	public Object getFieldValue(JRField field) throws JRException {

		 HistSolicitud histSolicitud = (HistSolicitud)lstDatos.get(index);
		 Object value = null;
		 String fieldName = field.getName();		
				 	 
		 	if ("codigoSolicitud".equals(fieldName)){
				value = histSolicitud.getCodSoli();
			}
			else if ("fecha".equals(fieldName)){
				value = histSolicitud.getFechaDate();
			}
			else if ("observaciones".equals(fieldName)){
				value = (histSolicitud.getObs()==null)?"":histSolicitud.getObs();
			}
		 
		return value;
	}

	public boolean next() throws JRException {
		index++;
		return (index < this.lstDatos.size());
	}

}
